package com.uenpay.im.ui.old.activity.remark;

import com.qiyunxin.android.http.utils.StringUtils;
import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;
import com.uenpay.im.invokeitems.BaseHttpInvokeItem;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author SL
 * @created 2016-3-22 下午6:56:47
 * @copyRight http://www.qiyunxin.com
 * @function TODO
 */
public class SetFriendMemoInvokeItem extends BaseHttpInvokeItem {

	public class SetFriendMemoInvokeItemResult extends HttpInvokeResult {

	}

	public SetFriendMemoInvokeItemResult getOutPut() {
		return (SetFriendMemoInvokeItemResult) GetResultObject();
	}

	/**
	 * 
	 * @param custId
	 * @param nickname
	 * @param phonenumber
	 * @param memo
	 */
	public SetFriendMemoInvokeItem(String custId, String nickname,
			String phonenumber, String memo) {
		// http://api.qiyunxin.com/Friend/Friend/setFriendMemo?custid=&nickname=&phonenumber=&tagids=&memo=
		String url = APIConfiguration.getBaseUrl()
				+ "Friend/Friend/setFriendMemo?custid=" + custId + "&nickname="
				+ StringUtils.encodeParams(nickname) + "&phonenumber="
				+ phonenumber + "&memo=" + memo + "&"
				+ APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}
	
	@Override
	protected Object DeserializeResult(String responseBody) {
		SetFriendMemoInvokeItemResult result = new SetFriendMemoInvokeItemResult();
		JSONObject json = null;
		try {
			json = new JSONObject(responseBody);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		if (json == null) {
			return null;
		}
		result.status = json.optInt("status");
		result.msg = json.optString("msg");
		return result;
	}
}
